<?php

namespace app\item\controller;

use app\common\model\Wx;
use think\Controller;

class Jssdk extends Controller
{

    public function api()
    {
        //获取参数url
        $url = input('param.url', '');

        //加载JSSDK
        $jssdk = new Wx();
        $signPackage = $jssdk->sign($url);

        $data = [
            'code'  => 0,
            'msg'   => 'success',
            'data'  => [
                'debug'     => false,
                'rawString' => $signPackage['rawString'],
                'appId'     => $signPackage['appId'],
                'timestamp' => $signPackage['timestamp'],
                'signature' => $signPackage['signature'],
                'nonceStr'  => $signPackage['nonceStr'],
                'jsApiList' => [
                    'checkJsApi',
                    'onMenuShareTimeline',
                    'hideOptionMenu',
                    'onMenuShareAppMessage',
                    'hideMenuItems',
                    'showMenuItems',
                ],
            ],

        ];

        return json($data);
    }

    public function index()
    {
        //获取参数url
        $url = input('param.url', '');

        //加载JSSDK
        $jssdk = new Wx();
        $signPackage = $jssdk->sign($url);

        $data = [
            'config'  => [
                'appId'     => $signPackage['appId'],
                'timestamp' => $signPackage['timestamp'],
                'signature' => $signPackage['signature'],
                'nonceStr'  => $signPackage['nonceStr'],
            ],

        ];

        return json($data);
    }



}
